home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.dsp,comp.lang.c
- Subject: Re: C code .vs. Assembly code for Microcontrollers/DSPs ?
- Date: Fri, 29 Mar 96 19:29:42 GMT
- Organization: none
- Message-ID: <828127782snz@genesis.demon.co.uk>
- References: <620174950wnr@dstrip.demon.co.uk> <4j9lfh$o2l@narses.hrz.tu-chemnitz.de> <436922997wnr@dstrip.demon.co.uk>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <436922997wnr@dstrip.demon.co.uk>
- Steve@dstrip.demon.co.uk "Steve Rencontre" writes:
-
- >In article: <4j9lfh$o2l@narses.hrz.tu-chemnitz.de>
- >hfst@hrz.tu-chemnitz.de (Hans Steffani) writes:
- >> Steve Rencontre <Steve@dstrip.demon.co.uk> writes:
- >>
- >> >Oh yes it can!
- >>
- >> > ...
- >> > int var1, var2;
- >> > int *var1p = &var1;
- >> > var1p[-1] = 0;
- >> > ...
- >>
- >> Post this to comp.lang.c[.moderated] and you will be told that this
- >> leads to undefined behavior and something like that.
- >
- >Well my newsreader doesn't know how to post to moderated groups, and I'm
- >too lazy to do it by hand :-), but anyway...
-
- Have you tried posting as normal?
-
- >It may be undefined by the *language*, but then so is the size of an
- >int!
-
- The size of an int is implementation defined so it is guaranteed to have a
- value. Moreover the language guarantees that you can store any number in
- the range -32767 to 32767 inclusive in an int on any implementation. That
- is a world apart from the plain undefined behaviour that the code above
- results in.
-
- >However, this very behaviour is relied on by stdargs/varargs in
- >order to make variable parameter lists possible. Yes, it's
- >implementation-dependent -- but that doesn't mean it results in
- >unpredictable or unreliable behaviour within that implementation.
-
- True, but it does mean that it is non-portable. Not knowing the intent and
- use of the code from what has appeared in comp.lang.c I cannot say
- whether that is significant or not. Usually it is.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-